package com.dayuanit.dy17.library.controller;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class PagesController extends BaseController {

    public PagesController() {
        System.out.println("-----------PagesController()---------------");
    }

    @RequestMapping("/page/toPage.do")
    public String toPage(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String pageName = req.getParameter("pageName");

        //这叫重定向
//        resp.sendRedirect("/WEB-INF/pages/" + pageName);
//        resp.sendRedirect("http://jd.com");

        resp.setContentType("text/html;charset=utf-8");

        //服务器内部跳转
        return pageName;
    }
}
